#ifndef __SCENEOBJECTNAVIGATIONMAP_H__
#define __SCENEOBJECTNAVIGATIONMAP_H__

#include <renderer.h>
#include <stl/list.h>
#include <standard/reference.h>
#include <standard/texturebuffer.h>
#include <standard/xml.h>
#include <standard/filewriter.h>

#define NAVIGATIONINFOCOUNT (8)

struct SNavigationLayerDataInfo{
    int32 m_nValue;
    color32 m_cColor;
};

class CSceneObjectBase;
struct SNavigationMapInfo{
    CSceneObjectBase* m_pSO;
    SNavigationLayerDataInfo m_vInfoList[NAVIGATIONINFOCOUNT];
};

class CSceneObjectNavigationMap: public CRefObject{
public:
    CSceneObjectNavigationMap();
    virtual ~CSceneObjectNavigationMap();
    void SetSize( class CTerrainObject* pTerrainObject, int32 nBlockCountX, int32 nBlockCountY, float fBlockSize, float fObjectUnitSize );
    bool32 Open( class CTerrainObject* pTerrainObject, CXML* pXML, HXMLNODEHANDLE hSceneHandle );
	void Save( CFileWriter* pFileWriter );
    bool32 WorldToCellCoords( float x, float y, int32* x_, int32* y_ );
    //int32 GetCellTypeListValue( int32 nCellType, int32 nDirType, int32 nAchorX, int32 nAchorY, list<TPosition>* pCellPostionList_);
    CSceneObjectBase* GetSOInfo( int32 x, int32 y );
    bool32 CellSOListIsNULL( list<TPosition>* pCellPositionList );
    bool32 SetSOInfo( int32 x, int32 y, CSceneObjectBase* pValue );
    bool32 SetSOListValue( list<TPosition>* pCellPositionList, CSceneObjectBase* pValue );
    bool32 CheckSOListValue( list<TPosition>* pCellPositionList, CSceneObjectBase* pValue );
    bool32 CheckCanPutSOList( list<TPosition>* pCellPositionList, CSceneObjectBase* pValue );
    //CSceneObjectBase*** GetCellInfo(){ return m_ppNavigCellObjectInfo; }
    int32 GetCellTypeListValue( int32 nCellType, int32 nDirType, int32 nAchorX, int32 nAchorY, list<TPosition>* pCellPostionList_ );
    SNavigationLayerDataInfo* GetInfoItem( int32 x, int32 y );
    void SetTextureDataType( int32 nIndex );
    int32 GetTextureDataType(){ return m_nTextureDataType; }
    void UpdateGeometry();
    void UpdateTextureData();

public:
    SNavigationMapInfo** m_ppNavigationMapInfoList;
    int32 m_nNavigCellSizeX;
    int32 m_nNavigCellSizeY;
    float m_fCellBlockWidth;
    float m_fCellBlockHeight;
    float m_fStartPosX;
	float m_fStartPosY;

public:
    class CTerrainObject* m_pTerrainObject;
    Ref< CTextureBuffer*> m_rNavicationMapTextureBuffer;
    color32 **m_ppNavicationTextureData;
    int32 m_nTextureDataType;

    uint32* m_pIndexData;
    int32 m_nIndexCount;
    TV3T2* m_pVertexData;
    int32 m_nVertexDataCount;
    Ref< class CIndexBuffer*> m_rIndexBuffer;
    Ref< class CVertexBuffer* > m_rVertexBuffer;
};




#endif
